package com.ai.manager.edu.cms.info.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ai.common.utils.pagination.PaginationUtil;
import com.ai.dao.edu.cms.info.InfoPushDetailMapper;
import com.ai.manager.edu.cms.info.InfoPushDetailManager;
import com.ai.model.edu.cms.info.InfoPushDetail;
import com.ai.model.edu.cms.info.dto.InfoPushDetailDTO;
import com.ai.model.edu.cms.info.vo.InfoPushDetailVO;

@Component("infoPushDetailManager")
public class InfoPushDetailManagerImpl implements InfoPushDetailManager {
    @Resource
    private InfoPushDetailMapper infoPushDetailMapper;


    /**
     * 根据主键查询记录
     */
    public List<InfoPushDetailVO> findInfoPushDetailById(Long id) {
    	return infoPushDetailMapper.findInfoPushDetailByAppId(id);
    }
    
    /**
     * 根据主键ID集合查询记录
     */
    public List<InfoPushDetailVO> findInfoPushDetailByAppIds(List<Long> ids) {
    	List<InfoPushDetailVO> result = new ArrayList<InfoPushDetailVO>();
    	List<List<Long>> split = PaginationUtil.split(ids, 50);
    	for(List<Long> appIds : split){
    		List<InfoPushDetailVO> list = infoPushDetailMapper.findInfoPushDetailByAppIds(appIds);
    		result.addAll(list);
    		
    	}
    	return result;
    }

	@Override
	public void insertInfoPushDetail(InfoPushDetail infoPushDetail) {
		infoPushDetailMapper.insertInfoPushDetail(infoPushDetail);
		
	}

	@Override
	public void updateInfoPushDetail(InfoPushDetailDTO infoPushDetailDTO) {
		infoPushDetailMapper.updateInfoPushDetail(infoPushDetailDTO);
	}

	@Override
	public void batchInsertInfoPushDetail(List<InfoPushDetail> detaillist) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("detaillist", detaillist);
		infoPushDetailMapper.batchInsertInfoPushDetail(map);
	}

	@Override
	public void deleteInfoPushDetailByPushId(InfoPushDetailDTO infoPushDetailDTO) {
		infoPushDetailMapper.deleteInfoPushDetailByPushId(infoPushDetailDTO);
	}

}